angular.module('YhyApp').controller('loginController', function($rootScope, $scope, $http, $timeout,$state) {
	$scope.$on('$viewContentLoaded', function() {
		$scope.modal = {
			title:'登录'
		};
		$scope.back = function() {
			history.back();
		};
		
		  
	    //用户验证，随输入实时提醒，这里只判断用户名是否存在和空值，还可以验证输入字符的长度、格式等
//	    $scope.existUser=function(){  
//	        for(var i=0;i<user.length;i++){  
//		        if(user.username[i]==$scope.username&&user.password[i]==$scope.password){  
//		           $scope.modal.login=false;  
//		        }else{  
//		           console.log(321);
//		        }  
//	        }  
//	    }  
	    
	    //登陆跳转,传数据到后台判断用户名和密码是否匹配，模拟http请求
	    $scope.Login=function(){  
	    	$http.get("接口")
			.then(function (response) {
				$scope.user = response.data;
				console.log($scope.user);
				for(var i=0;i<$scope.user.length;i++){  
			        if($scope.user[i].username==$scope.username&&$scope.user[i].password==$scope.password){  
			           $state.go('my',{},{reload:true});
			        }else{  
			           console.log("账号密码错误！");
			        }  
		        }  
			});
	 		
	    };
		
	});
});